In this set of exercises, we clone and work on the GitHub or GitLab repository you have created in the previous session.
In order to do the following exercises, you should have gone through the steps described in the setup information for the workshop. Specifically, you should…
Git via RStudioHTTPS for GitHubFor using GitLab you should also have enabled SSH authentication through creating a RSA key in the Git/SVN options in RStudio.
Git, enter the URL of the GitHub/GitLab repository (remember that the URL looks different depending on whether you use HTTPS or SSH for authentication), and choose a location where to store the project on your local machine. As we will start working on the project right away, also check “Open in new session”.
Git tab. To make extra sure that everything worked, let’s check the Git status of our project via the Terminal in RStudio.
Terminal in RStudio uses via Tools -> Global Options -> Terminal. If you use Windows, you should choose Git Bash (which you should have installed with Git for Windows).
git status
Now that the project is set up and in sync with the remote repository, we can start working on it. Modify the README file (just add, remove or edit a few words). If you want to, you can also edit the R Markdown file(s) in your repository/project.
Git.
Git tab in RStudio and their status will be indicated as modified or untracked.
Git tab.
Git tab in RStudio, write a commit message in the menu that opens up, and then click the Push button in the same menu.
As a final exercise for this session, let’s do the opposite of pushing and pull changes from the remote repository to your local project. Before we can do this, we first need to make some edits in the remote repository. Go to the website of your remote GitHub/GitLab repository (while being logged in) and edit the README file in the browser (again, just add, remove, or edit a few words). How you edit a file depends on the platform:
On GitHub: You can edit the README via the small pen icon next displayed above the content of your README file.
On GitLab: Click on the name of the file you want to edit (in this case this should be README.md). Next, choose and click “Edit” from the blue dropdown menu shown next to the file name.
Git tab in RStudio to update your local project.